function swap(arr, a, b){
  let c = arr[a];
  arr[a] = arr[b];
  arr[b] = c;
}

var exchange = function(nums) {
  return quick_sort(nums, 0 , nums.length - 1)
  function quick_sort(arr, l, r){
      if(l >= r) return arr;
      let x = l, y = r;
      while(x < y){
        while(x < y && (arr[x] & 1) === 1) {
          x++;
        }
        while(x < y && (arr[y] & 1) === 0) {
          y--;
        }
        swap(arr, x , y);
        x++, y--;
      }
      return arr;
  }
};